package practice06;

import java.util.Scanner;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice06
 * @ClassName: TestCalculator
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/1 16:35
 * @Copyright 大牛版板所有
 */
public class TestCalculator {
    public static void main(String[] args) {
        Calculator cal = new Calculator();
        Scanner input = new Scanner(System.in);
        System.out.print("请输入第一个整数：");
        cal.firstNum = input.nextInt();
        System.out.print("请输入第二个整数：");
        cal.secondNum = input.nextInt();
        System.out.println("1.加，2.减，3.乘，4.除");
        System.out.print("请选择运算符：");
        int claNum = input.nextInt();
        double result;
        switch (claNum){
            case 1:
                result = cal.add();
                System.out.println("加法："+result);
                break;
            case 2:
                result = cal.sub();
                System.out.println("减法："+result);
                break;
            case 3:
                result = cal.mul();
                System.out.println("乘法："+result);
                break;
            case 4:
                if (cal.secondNum != 0){
                    result = cal.div();
                    System.out.println("除法："+result);
                    break;
                }
                else {
                    System.out.println("0不能做除数，无法运算！");
                    break;
                }
            default:
                System.out.println("你输入的运算符无效！");
        }
    }
}
